<?php 
/**
 * ... ...
 * ... ...
 *
 */ 


JCAT_Package::ImportClass('JCAT_ViewGtk',JCAT::PACKAGE_MVCGTK) ;
JCAT_Package::ImportInterface('JCAT_IViewForm',JCAT::PACKAGE_MVC) ;


/**
 * 视图类 StartWindowView 
 *
 * @access public
 */
class StartWindowView 
	//<<[UnmodifiableBlock.Start]::Extends And Implements::>>//
	extends JCAT_ViewGtk
	implements JCAT_IViewForm
	//<<[UnmodifiableBlock.End]::Extends And Implements::>>// 
{
	
	/**
	 * 构造函数 
	 *
	 * @access	public
	 * @param	$aParent	JCAT_IViewContainer		视图的父对象(父视图 或 控制器)。注意：视图不应单独存在，必须有一个父对象！ 
	 * @return	void
	 */
	public function StartWindowView(JCAT_IViewContainer $aParent)
	{
		// 调用父类构造函数 
		//<<[UnmodifiableBlock.Start]::Call Parent Construct::>>//
		$this->JCAT_ViewGtk('StartWindowView','../../Resource/Template/template.StartWindow.glade','StartWindow',$aParent) ;
		//<<[UnmodifiableBlock.End]::Call Parent Construct::>>// 

		$this->Initialize() ;	
	}
	
	/**
	 * 初始化 视图 
	 *
	 * @access	protected
	 * @return	void
	 */
	protected function Initialize()
	{
		//<<[UnmodifiableBlock.Start]::UICtrl Children::>>//
		// 载入UI控件
		$sCurrentDirectory = dirname(__FILE__).'/' ;
		JCAT_Package::ImportClass('LstRecentFile',$sCurrentDirectory.'Instance.UICtrls/class.LstRecentFile.php') ;
		$this->AddUICtrl(new LstRecentFile()) ;
		//<<[UnmodifiableBlock.End]::UICtrl Children::>>// 
		
		//<<[UnmodifiableBlock.Start]::View Children::>>//

		//<<[UnmodifiableBlock.End]::View Children::>>// 
		
		
		// 在此加入其它初始化代码 
	 	// TODO ... ...

		$this->aCodersModel = new GtkListStore(
			GdkPixbuf::gtype
			, gtk::TYPE_STRING
			, gtk::TYPE_STRING
			, gtk::TYPE_STRING
		) ;
	}

	/**
	 * 创建主窗体事件 
	 *
	 * @access	protected
	 * @return	void
	 */
	protected function OnInitView()
	 {
		 $wndTreeCoders = $this->GetChildWidget('TreeCoders') ;
		 $wndTreeCoders->set_model($this->aCodersModel) ;
		 $wndTreeCoders->set_pixbuf_column(self::CLM_PIXBUF) ;
		 $wndTreeCoders->set_text_column(self::CLM_TEXT) ;
		 $wndTreeCoders->set_markup_column(self::CLM_MARKUP) ;
		 
		 
		 // Coder 类别 按钮
		 $wndVBtnBoxForCoderKind = $this->GetChildWidget('VBtnBoxForCoderKind') ;
		 
		foreach (self::$arrCoders as $sKindName=>$arrCoderKind)
		{$arrCoderKind ;
			$sLabel = JCAT_Language::Sentence($sKindName) ;
			$wndButton = new GtkToggleButton($sLabel);
			$wndVBtnBoxForCoderKind->add($wndButton) ;
			$wndButton->set_visible( true, false ) ;
			$wndButton->set_focus_on_click( false ) ;
			$wndButton->connect_simple_after('clicked',array($this,'OnCoderKindBtnClick'),$wndButton,$sKindName);
		}
		

		$wndBtnRecentCoder = $this->GetChildWidget('BtnRecentCoder') ;
		$wndBtnAllCoder = $this->GetChildWidget('BtnAllCoder') ;
		$wndBtnRecentCoder->connect_simple_after('clicked',array($this,'OnCoderKindBtnClick'),$wndBtnRecentCoder,'recent');
		$wndBtnAllCoder->connect_simple_after('clicked',array($this,'OnCoderKindBtnClick'),$wndBtnAllCoder,'all');
		 
	 }


	 
	 /**
	  * what's this
	  * 
	  * @access	public
	  * @return	void
	  */
	 public function LoadCoder($sKindName)
	 {
	 	// 清除
	 	$this->aCodersModel->clear() ;

	 	// 
	 	if( !isset(self::$arrCoders[$sKindName]) )
	 	{
	 		return ;
	 	}

		foreach (self::$arrCoders[$sKindName] as $arrCoder)
		{
			$arrItem[self::CLM_TEXT] = $arrCoder['name'] ;
			$arrItem[self::CLM_MARKUP] = $arrCoder['intro'] ;
			$arrItem[self::CLM_CLASS] = $arrCoder['class'] ;
			
			if( isset($arrCoder['icon']) and is_file($arrCoder['icon']) )
			{
				$aIcon = GdkPixbuf::new_from_file(ROOT_PATH.$arrCoder['icon']) ;
			}
			else 
			{
				$aIcon = null ;
			}
			$arrItem[self::CLM_PIXBUF] = $aIcon ;
			ksort($arrItem) ;

			$this->aCodersModel->append($arrItem);
		}
	 	
	 }
	 
	 /**
	  * what's this
	  * 
	  * @access	public
	  * @return	void
	  */
	 public function OnCoderKindBtnClick(GtkToggleButton $wndClickBtn=null,$sKindName=null)
	 {
	 	// 按钮之间切换
	 	if(!$this->bCoderKindConnectClick)
	 	{
	 		return ;
	 	}
	 	
	 	$wndVBtnBoxForCoderKind = $this->GetChildWidget('VBtnBoxForCoderKind') ;
	 	$arrBtns = $wndVBtnBoxForCoderKind->get_children() ;
	 	
	 	$this->bCoderKindConnectClick = false ;
	 	foreach ($arrBtns as $wndBtn)
	 	{
	 		$wndBtn->set_active(false) ;
	 	}
	 	
	 	$wndClickBtn->set_active(true) ;
	 	
	 	$this->bCoderKindConnectClick = true ;
	 	
	 	// 载入 图表
	 	$this->LoadCoder($sKindName) ;
	 }
	 
	 
	 /**
	  * what's this
	  * 
	  * @access	public
	  * @return	void
	  */
	 public function OnDBClickCoder(GtkIconView $aIconView, array $arrItemPath)
	 {$aIconView ;

	 	// 选择目录
	 	$sPath = JCAT_GtkFSDialog::Choose(Gtk::FILE_CHOOSER_ACTION_SELECT_FOLDER,$sPath) ;
	 	if( !is_dir($sPath) )
	 	{
	 		return ;
	 	}
	 	
	 	// 创建 Coder 窗口
	 	$arrArg['path'] = $sPath ;

	 	$aItem = $this->aCodersModel->get_iter_from_string(implode(':',$arrItemPath)) ;
	 	$sClass = $this->aCodersModel->get_value($aItem,self::CLM_CLASS);
	 	
	 	$aCoder = new $sClass() ;
	 	$aCoder->MainRun(&$arrArg) ;
	 	//$this->arrItemPath ;
	 }


	 /**
	  * what's this
	  * 
	  * @access	public
	  * @return	void
	  */
	 public function OnOpenFile()
	 {
	 	$aController = new OpenCoderDocument() ;
	 	$aController->MainRun() ;
	 }

	 /**
	  * 
	  * 
	  * @access	private
	  * @var	GtkListStore
	  */
	 private $aCodersModel ;


	 const CLM_PIXBUF = 0 ;
	 const CLM_TEXT = 1 ;
	 const CLM_MARKUP = 2 ;
	 const CLM_CLASS = 3 ;
	 
	 /**
	  * 
	  * 
	  * @access	private
	  * @var	bool
	  */
	 private $bCoderKindConnectClick = true ;
	 
	 /**
	  * 
	  * 
	  * @access	private
	  * @var	array
	  * @static
	  */
	 static private $arrCoders = array(
	 
	 	// 项目 ::::::::::::::::::::::::::
	 	'项目' => array(
	 
	 		array(
	 			'name' => 'JCAT Web' ,
	 			'intro' => 'JCAT Web 项目' ,
	 			'class' => ''
	 		)
	 		, array(
	 			'name' => 'JCAT Desktop' ,
	 			'intro' => 'JCAT Desktop 项目' ,
	 			'class' => ''
	 		)
	 		, array(
	 			'name' => 'JCAT Command Line' ,
	 			'intro' => 'JCAT 命令行项目' ,
	 			'class' => ''
	 		)
	 	) ,
	 	
	 	// MVC 类 ::::::::::::::::::::::::::
	 	'MVC类' => array(

	 		array(
	 			'name' => '控制器' ,
	 			'intro' => '控制器' ,
	 			'icon' => 'Resource/Image/Controller.24x24.png' ,
	 			'class' => 'Controller'
	 		)
	 		, array(
	 			'name' => '数据库文档' ,
	 			'intro' => 'JCAT_DBDocument 文档' ,
	 			'icon' => 'Resource/Image/Document.24x24.png',
	 			'class' => 'DBDocument'
	 		)
	 		, array(
	 			'name' => '数据库聚合文档' ,
	 			'intro' => 'JCAT_DBAggregationDocument 文档' ,
	 			'icon' => 'Resource/Image/Document.24x24.png',
	 			'class' => 'DBAggregationDocument'
	 		)
	 		, array(
	 			'name' => 'HTML视图' ,
	 			'intro' => 'HTML网页视图' ,
	 			'icon' => 'Resource/Image/View.24x24.png',
	 			'class' => 'ViewHtml'
	 		)
	 		, array(
	 			'name' => 'Gtk桌面视图' ,
	 			'intro' => 'Gtk桌面视图' ,
	 			'icon' => 'Resource/Image/View.24x24.png',
	 			'class' => 'ViewGtk'
	 		)
	 	) ,
	 	
	 	// UI控件 ::::::::::::::::::::::::::
	 	'UI控件' => array(

	 		array(
	 			'name' => '文本输入' ,
	 			'intro' => '文本输入' ,
	 			'class' => 'UICtrlText'
	 		)
	 		, array(
	 			'name' => '菜单/列表/HTML 单选、复选' ,
	 			'intro' => '菜单/列表/HTML 单选、复选' ,
	 			'class' => 'UICtrlSelect'
	 		)
	 		, array(
	 			'name' => '控件组' ,
	 			'intro' => '控件组' ,
	 			'class' => 'UICtrlGroup'
	 		)
	 		, array(
	 			'name' => 'Gtk树型视图' ,
	 			'intro' => 'Gtk树型视图' ,
	 			'class' => 'UICtrlGtkTree'
	 		)
	 		, array(
	 			'name' => 'Gtk状态按钮' ,
	 			'intro' => 'Gtk状态按钮' ,
	 			'class' => 'UICtrlGtkToggle'
	 		)
	 	) ,
	 	
	 ) ;
}

?><?
/**
 * [注意!!]
 *	以下内容由 JCAT PHP Toolbox 自动维护，手动更改的内容会被 JCAT PHP Toolbox 抹除，
 *	同时还可能破坏格式，导致 JCAT PHP Toolbox 无法正常读取。
 */
/*<<[UnmodifiableBlock.Start]::Coder Dialog Data::>>&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&//
<<{{DocumentClass:ViewGtkDoc}}>>
eCVEQSU5RFQlREIlOEUlRDMwJTEwJTdERyVFMiUyMyVDOCUwN2wlOTJuJTJCKyU4QiU5MCVEQSU1QyU5NiU5OHUlQkFuYlclRTUlMDUlODUlRDRqJUQzJUI4JUNEJUQyJTA0ZSVEM1UlRkYlOURjJTk3LSVCNyUwNSUyMSUxRUYlQjZnJUM2JUUzM3NOJTkyJTdCJTAzJUVGJUExJUYxJTg2JTlFJTE1JUU0bW4lNUQlRTUl
REVLJTdEdiUyRiUzREslOTQlQjIlRjNVJURFNEklQkUlOTUlRDYlMTUlOUMlMDMlQ0YlMj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